using System;
using System.Collections.Generic;
using System.Text;

using phorm.model.fields;
using phorm.database.mssql;

namespace phorm
{
    public class Author : MSSQLRecord
    {
        public PrimaryKey AuthorID;
        public Varchar AuthorFirstName;
        public Varchar AuthorLastName;
        public MD5Password Password;

        public Author()
        {
            AuthorID = new PrimaryKey(this);
            AuthorFirstName = new Varchar(this, 50);
            AuthorLastName = new Varchar(this, 50);
            Password = new MD5Password(this);
        }
    }

    public class Publisher : MSSQLRecord
    {
        public PrimaryKey PublisherID;
        public Varchar PublisherName;

        public Publisher()
        {
            PublisherID = new PrimaryKey(this);
            PublisherName = new Varchar(this, 50);
        }
    }

    public class Book : MSSQLRecord
    {
        public PrimaryKey              BookID;
        public Varchar                 BookName;
        public Integer                 ISBN;
        public SQLDecimal              Price;
        public ManyToMany<Author>      Authors;
        public ManyToMany<Book>        RelatedBooks;
        public ForeignKey<Publisher>   PublisherID;
        public CreationSQLDateTime     CreateDate;
        public LastModifiedSQLDateTime LastModDate;

        public Book()
        {
            BookID       = new PrimaryKey(this);
            BookName     = new Varchar(this);
            ISBN         = new Integer(this);
            Price        = new SQLDecimal(this, 6, 2);
            Authors      = new ManyToMany<Author>(this);
            RelatedBooks = new ManyToMany<Book>(this);
            PublisherID  = new ForeignKey<Publisher>(this);
            CreateDate   = new CreationSQLDateTime(this);
            LastModDate  = new LastModifiedSQLDateTime(this);
        }
    }

    public class Order : MSSQLRecord
    {
        public PrimaryKey OrderID;
        public Varchar OrderName;
        public ManyToMany<Book> Books;
        public CreationSQLDateTime OrderDate;
        public LastModifiedSQLDateTime LastEdit;

        public Order()
        {
            OrderID = new PrimaryKey(this);
            OrderName = new Varchar(this, 50);
            Books = new ManyToMany<Book>(this);
            OrderDate = new CreationSQLDateTime(this);
            LastEdit = new LastModifiedSQLDateTime(this);
        }
    }
}
